<template>
  <el-dialog
    title="班级列表"
    :close-on-click-modal="false"
    :visible.sync="visible"
    class="JADP-dialog JADP-dialog_center"
    lock-scroll
    width="70%"
  >
    <JADP-table
      v-loading="loading"
      :data="list"
      @sort-change="sortChange"
      has-c
      @selection-change="handleSelectionChange"
      :row-style="{ cursor: 'pointer' }"
    >
      <el-table-column
        prop="classname"
        label="班级名称"
        align="left"
        show-overflow-tooltip
      />
      <el-table-column
        prop="categorytype"
        label="行业类型"
        align="left"
        width="135"
      >
        <template v-slot="{ row }">
          {{ getDict("hangye", row.categorytype) }}
        </template>
      </el-table-column>
      <el-table-column label="培训类别" prop="trainType" algin="left">
        <template slot-scope="scope">
          {{ getDict("pxlb", scope.row.trainType) }}
        </template>
      </el-table-column>

      <el-table-column
        prop="signupdateStart"
        label="报名开始时间"
        width="135"
        align="left"
      >
        <template v-slot="{ row }">
          {{ row.signupdateStart | dateFormat }}
        </template>
      </el-table-column>
      <el-table-column
        prop="signupdateEnd"
        label="报名结束时间"
        width="135"
        align="left"
      >
        <template v-slot="{ row }">
          {{ row.signupdateEnd | dateFormat }}
        </template>
      </el-table-column>
      <el-table-column
        prop="traindateStart"
        label="培训开始时间"
        align="left"
        width="135"
      >
        <template v-slot="{ row }">
          {{ row.traindateStart | dateFormat }}
        </template>
      </el-table-column>
      <el-table-column
        prop="traindateEnd"
        label="培训结束时间"
        align="left"
        width="135"
      >
        <template v-slot="{ row }">
          {{ row.traindateEnd | dateFormat }}
        </template>
      </el-table-column>
      <el-table-column label="培训方式" prop="trainMode" algin="left">
        <template slot-scope="scope">
          {{ getDict("bjpxfs", scope.row.trainMode) }}
        </template>
      </el-table-column>

      <el-table-column prop="hours" label="学时" align="left" />
    </JADP-table>
    <pagination
      :total="total"
      :page.sync="listQuery.currentPage"
      :limit.sync="listQuery.pageSize"
      @pagination="initData"
    />
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" @click="dataFormSubmit">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
import request from "@/utils/request";
export default {
  name: "clazztable",
  props: {
    paperid: {
      type: String
    }
  },
  data() {
    return {
      visible: false,
      loading: false,
      total: 0,
      listQuery: {
        currentPage: 1,
        pageSize: 20,
        sort: "desc",
        sidx: ""
      },
      list: [],
      currentRow: null
    };
  },
  methods: {
    initData() {
      this.visible = true;
      this.loading = true;
      let _query = {
        ...this.listQuery,
        ...this.query,
        paperid: this.paperid,
        organizeId:this.$store.getters.organizeId
      };
      let query = {};
      for (let key in _query) {
        if (Array.isArray(_query[key])) {
          query[key] = _query[key].join();
        } else {
          query[key] = _query[key];
        }
      }
      request({
        url: `/api/statistics/StatisticsController/getClazzList`,
        method: "get",
        data: query
      }).then(res => {
        this.list = res.data.list;
        this.total = res.data.pagination.total;
        console.log(res, 22);
        this.loading = false;
      });
    },

    handleCurrentChange(val) {
      console.log(val);
      this.currentRow = val;
    },

    sortChange({ column, prop, order }) {
      this.listQuery.sort = order == "ascending" ? "asc" : "desc";
      this.listQuery.sidx = !order ? "" : prop;
      this.initData();
    },

    search() {
      this.listQuery = {
        currentPage: 1,
        pageSize: 20,
        sort: "desc",
        sidx: ""
      };
      this.initData();
    },

    reset() {
      for (let key in this.query) {
        this.query[key] = undefined;
      }
      this.listQuery = {
        currentPage: 1,
        pageSize: 20,
        sort: "desc",
        sidx: ""
      };
      this.initData();
    },

    dataFormSubmit() {
      this.$emit("multipleSelection", this.multipleSelection);
      this.visible = false;
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    }
  }
};
</script>
<style scoped lang="scss"></style>
